翻訳と辞書
Words near each other
・ Copy & Pastry
・ Copy (album)
・ Copy (command)
・ Copy (musician)
・ Copy (written)
・ Copy and paste programming
・ Copy attack
・ Copy boy
・ Copy Cats (album)
・ Copy Cats (short story collection)
・ Copy constructor (C++)
・ Copy Control
・ Copy Control Information
・ Copy Cursor
・ Copy editing
Copy elision
・ Copy Exactly!
・ Copy number analysis
・ Copy of a
・ Copy of Lute Player by Frans Hals
・ Copy propagation
・ Copy protection
・ Copy stand
・ Copy testing
・ Copy to China
・ Copy trading
・ Copy typist
・ Copy, Paste
・ Copy-evident document
・ Copy-number variation


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Copy elision : ウィキペディア英語版
Copy elision

In C++ computer programming, copy elision refers to a compiler optimization technique that eliminates unnecessary copying of objects. The C++ language standard generally allows implementations to perform any optimization, provided the resulting program's observable behavior is the same ''as if'', i.e. pretending, the program was executed exactly as mandated by the standard.
The standard also describes a few situations where copying can be eliminated even if this would alter the program's behavior, the most common being the return value optimization. Another widely implemented optimization, described in the C++ standard, is when a temporary object of class type is copied to an object of the same type.〔ISO/IEC (2003). ''ISO/IEC 14882:2003(E): Programming Languages - C++ §12.8 Copying class objects ()'' para. 15〕 As a result, ''copy-initialization'' is usually equivalent to ''direct-initialization'' in terms of performance, but not in semantics; ''copy-initialization'' still requires an accessible copy constructor.〔
〕 The optimization can not be applied to a temporary object that has been bound to a reference. Example:

#include
int n = 0;
struct C // the copy constructor has a visible side effect
}; // it modifies an object with static storage duration
int main()

According to the standard a similar optimization may be applied to objects being thrown and caught,〔ISO/IEC (2003). ''ISO/IEC 14882:2003(E): Programming Languages - C++ §15.1 Throwing an exception ()'' para. 5〕〔ISO/IEC (2003). ''ISO/IEC 14882:2003(E): Programming Languages - C++ §15.3 Handling an exception ()'' para. 17〕 but it is unclear whether the optimization applies to both the copy from the thrown object to the ''exception object'', and the copy from the ''exception object'' to the object declared in the ''exception-declaration'' of the ''catch clause''. It is also unclear whether this optimization only applies to temporary objects, or named objects as well.〔(【引用サイトリンク】title=C++ Standard Core Language Defect Reports )〕 Given the following source code:

#include
struct C
};
void f() // It is unclear whether this copy may be elided.
int main() // It is also unclear whether this copy may be elided.
}

A conforming compiler should therefore produce a program which prints "Hello World!" twice. In the current revision of the C++ standard (C++11), the issues have been addressed, essentially allowing both the copy from the named object to the exception object, and the copy into the object declared in the exception handler to be elided.〔(【引用サイトリンク】title=C++ Standard Core Language Defect Reports )
GCC provides the -fno-elide-constructors option to disable copy-elision. This option is useful to observe (or not observe!) the effects of Return Value Optimization or other optimizations where copies are elided. It is generally not recommended to disable this important optimization.
== References ==


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Copy elision」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.